#include "StdAfx.h"
#include "SerialHal.h"

SerialHal::SerialHal(void)
{
}

SerialHal::~SerialHal(void)
{
}


bool SerialHal::Write( void* buf, DWORD len, DWORD& realLen )
{
	GD_DUMP("serial-hal write",buf, len);
	realLen = serial_.ComWrite(buf, len);
	return true;
}

void SerialHal::Read( void* buf, DWORD len, DWORD& realLen )
{
	realLen = serial_.ComRead(buf,len);
	GD_DUMP("serial-hal read",buf, realLen);
}


HANDLE SerialHal::CreateFile( CString fileName )
{
	GD_DBG_LOG("serial-hal create file %s",fileName.GetBuffer());
	BOOL res = serial_.ComOpen((LPTSTR)(LPCTSTR)fileName,115200,8,0,0);
	GD_DBG_LOG("open serial-hal result %d", res);
	return serial_.m_hPort;
}
bool SerialHal::WriteReadEvent( HANDLE handle )
{
	return true;
}

